﻿<UserControl x:Class="SlotDuino.UI.Controls.RaceCreate"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dal="clr-namespace:SlotDuino.DAL;assembly=SlotDuino.DAL" 
             xmlns:converter="clr-namespace:SlotDuino.Converter"
             mc:Ignorable="d" 
             Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <CollectionViewSource x:Key="voltagesViewSource" d:DesignSource="{d:DesignInstance dal:Voltage, CreateList=True}" />
        <CollectionViewSource x:Key="slotsViewSource" d:DesignSource="{d:DesignInstance dal:Slot, CreateList=True }" />
        <CollectionViewSource x:Key="raceSlotsViewSource" d:DesignSource="{d:DesignInstance dal:RaceSlot, CreateList=True }" />
        <CollectionViewSource x:Key="pilotsViewSource" d:DesignSource="{d:DesignInstance dal:Pilot, CreateList=True }" />
        <converter:GreaterThenZero x:Key="GreaterThenZero" />
    </UserControl.Resources>

    <StackPanel Width="165">
        <Label Content="Apelido" Margin="0,0,0,5" />
        <ComboBox x:Name="cmbPilots" ItemsSource="{Binding Source={StaticResource pilotsViewSource}}" DisplayMemberPath="Nickname" SelectedValuePath="Id" Margin="0,0,0,5" IsEditable="True" />
		<Label Content="Fenda" Margin="0,0,0,5" />
		<ComboBox x:Name="cmbSlot" ItemsSource="{Binding Source={StaticResource slotsViewSource}}" DisplayMemberPath="Color" SelectedValuePath="Id" Margin="0,0,0,5" />
		<Label Content="Tensão" Margin="0,0,0,5" />
		<ComboBox x:Name="cmbVoltage" ItemsSource="{Binding Source={StaticResource voltagesViewSource}}" DisplayMemberPath="Label" SelectedValuePath="Id" Margin="0,0,0,5" />
        <Button Content="Adicionar" x:Name="btnAddToList" Click="btnAddToList_Click" HorizontalAlignment="Right" Width="80" Height="32" Margin="0,0,0,5" IsEnabled="{Binding Source={StaticResource slotsViewSource}, Path=Count, Converter={StaticResource GreaterThenZero}}" />
        <DataGrid Background="{StaticResource SelectedBackgroundBrush}" AutoGenerateColumns="False" ItemsSource="{Binding Source={StaticResource raceSlotsViewSource}}" MinHeight="170" Margin="0,0,0,5" CanUserAddRows="False">
			<DataGrid.Columns>
				<DataGridTextColumn Header="Slot" Binding="{Binding Slot.Color}" IsReadOnly="True" />
				<DataGridTextColumn Header="Piloto" Binding="{Binding Pilot.Nickname}" IsReadOnly="True" />
			</DataGrid.Columns>
		</DataGrid>
        <Label Content="Tempo de corrida" Margin="0,0,0,5" />
        <StackPanel Orientation="Horizontal" Margin="0,0,0,10">
            <TextBox x:Name="txtTime" Text="10" VerticalAlignment="Top" Width="45" Margin="0,0,5,0" />
            <ComboBox x:Name="cmbSegMin">
                <ComboBoxItem Content="minutos" IsSelected="True" />
                <ComboBoxItem Content="segundos" IsSelected="False" />
            </ComboBox>
        </StackPanel>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Content="Cancelar" x:Name="btnCancel" Height="32" Width="75" Margin="0,0,5,0" Click="btnCancel_Click" />
            <Button Content="Criar Corrida" x:Name="btnCreateRace" Height="32" Width="75" Click="btnCreateRace_Click" IsEnabled="{Binding Source={StaticResource raceSlotsViewSource}, Path=Count, Converter={StaticResource GreaterThenZero}}" />
        </StackPanel>
	</StackPanel>
</UserControl>
